package database;

public class dbUserImpl implements database.ints.dbUser {
    
	dbMain dbM=new dbMain();
	private String plrColID = "playerID";
    private String plrColName = "playerName";
    private String plrColPass = "pass";
    private String emptyString = "";
	
    @Override
	public boolean checkUserPwd(String userName, String userPass) {
		String passwd = dbM.getValue(dbM.URL_USER, plrColName, userName, plrColPass);
		if (userPass.equals(emptyString)) {
			return false;
		}
		if (userPass.equals(passwd)) {
			return true;
		}
		return false;
	}

	@Override
	public int createUser(String userName, String passwd) {
		dbM.addUser(userName, passwd);
		String pid = dbM.getValue(dbM.URL_USER, plrColName, userName, plrColID);
		return Integer.parseInt(pid);
	}

	@Override
	public String getUsername(String pid) {
		return dbM.getValue(dbM.URL_USER, plrColID, pid, plrColName);
	}

	@Override
	public String getPID(String userName) {
		return dbM.getValue(dbM.URL_USER, plrColName, userName, plrColID);
	}
}